﻿using Product.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UboxUI;

namespace Product
{
    public partial class FrmProductManager : FrmFather
    {
        public FrmProductManager()
        {
            InitializeComponent();

            this.BtnClose.Left = this.Width - this.BtnClose.Width - 10;
            this.BtnNarrow.Left = this.BtnClose.Left - this.BtnNarrow.Width - 10;
            this.panel1.Top = 0;
            this.panel2.Top = this.panel1.Height;
        }

        string conn = Settings.Default.strConn;
        bool isProCreate = FrmProductsControl.isProCreate;
        DataGridViewRow selectRow = FrmProductsControl.selectRow;
        int proID = FrmProductsControl.proID;

        private void FrmProductCreate_Load(object sender, EventArgs e)
        {
            DataLoad();
            this.LblTitle.Text = this.Text;
            this.LblTitle2.Text = this.Text;

        }

        private void DataLoad()
        {
            this.Cursor = Cursors.WaitCursor;
            #region Fill
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_camera' 資料表。您可以視需要進行移動或移除。
            this.production_cameraTableAdapter.Fill(this.UBOXDataSet.production_camera);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_srceen_resolution' 資料表。您可以視需要進行移動或移除。
            this.production_srceen_resolutionTableAdapter.Fill(this.UBOXDataSet.production_srceen_resolution);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_screen_size' 資料表。您可以視需要進行移動或移除。
            this.production_screen_sizeTableAdapter.Fill(this.UBOXDataSet.production_screen_size);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_processor_speed' 資料表。您可以視需要進行移動或移除。
            this.production_processor_speedTableAdapter.Fill(this.UBOXDataSet.production_processor_speed);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_processor_core' 資料表。您可以視需要進行移動或移除。
            this.production_processor_coreTableAdapter.Fill(this.UBOXDataSet.production_processor_core);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_connection_standard' 資料表。您可以視需要進行移動或移除。
            this.production_connection_standardTableAdapter.Fill(this.UBOXDataSet.production_connection_standard);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_operating_system' 資料表。您可以視需要進行移動或移除。
            this.production_operating_systemTableAdapter.Fill(this.UBOXDataSet.production_operating_system);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_ram' 資料表。您可以視需要進行移動或移除。
            this.production_ramTableAdapter.Fill(this.UBOXDataSet.production_ram);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.production_rom' 資料表。您可以視需要進行移動或移除。
            this.production_romTableAdapter.Fill(this.UBOXDataSet.production_rom);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.brand' 資料表。您可以視需要進行移動或移除。
            this.brandTableAdapter.Fill(this.UBOXDataSet.brand);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet1.category' 資料表。您可以視需要進行移動或移除。
            this.categoryTableAdapter.Fill(this.UBOXDataSet.category);
            // TODO:  這行程式碼會將資料載入 'uBOXDataSet.brand' 資料表。您可以視需要進行移動或移除。
            this.brandTableAdapter.Fill(this.UBOXDataSet.brand);

            this.production_functionTableAdapter1.Fill(this.UBOXDataSet.production_function);
            #endregion

            DataTable dt = this.UBOXDataSet.production_function;
            int proID = 0;

            foreach (DataRow dr in dt.Rows)
            {
                CheckBox myCheckBox = new CheckBox();
                myCheckBox.Text = dr["function"].ToString();
                myCheckBox.Tag = dr["function_id"];
                this.flpFunctionList.Controls.Add(myCheckBox);
            }

            if (!isProCreate)
            {
                this.Text = "修改商品";
                this.btnAdd.Text = "修改";
                UboxDataClassesDataContext db = new UboxDataClassesDataContext();

                #region step1: 載入商品屬性
                proID = (int)selectRow.Cells["product_id"].Value;
                this.txtProductName.Text = selectRow.Cells["product_name"].Value.ToString();
                this.txtPrice.Text = string.Format("{0:0}",selectRow.Cells["price"].Value);
                this.txtColor.Text = selectRow.Cells["color"].Value.ToString();
                this.txtSize.Text = selectRow.Cells["size"].Value.ToString();
                this.txtWeight.Text = string.Format("{0:0}",selectRow.Cells["weight"].Value);
                this.txtBatteryCapacity.Text = selectRow.Cells["battery_capacity"].Value.ToString();
                this.txtTalkTime.Text = string.Format("{0:0}",selectRow.Cells["battery_talk_time"].Value);

                this.cboCategory.SelectedValue = selectRow.Cells["category_id"].Value;
                this.cboBrand.SelectedValue = selectRow.Cells["brand_id"].Value;
                this.cboRom.SelectedValue = selectRow.Cells["rom_id"].Value;
                this.cboRam.SelectedValue = selectRow.Cells["ram_id"].Value;
                this.cboOS.SelectedValue = selectRow.Cells["operating_system_id"].Value;
                this.cboConnStandard.SelectedValue = selectRow.Cells["connect_id"].Value;
                this.cboCore.SelectedValue = selectRow.Cells["processor_core_id"].Value;
                this.cboSpeed.SelectedValue = selectRow.Cells["processor_speed_id"].Value;
                this.cboScreenSize.SelectedValue = selectRow.Cells["screen_size_id"].Value;
                this.cboScreenResolution.SelectedValue = selectRow.Cells["screen_resolution_id"].Value;
                this.cboRearCamera.SelectedValue = selectRow.Cells["rear_id"].Value;
                this.cboFrontCamera.SelectedValue = selectRow.Cells["front_id"].Value;
                #endregion

                #region step2: 載入功能項目

                var q = from f in db.production_product_funtion
                        where f.product_id == proID
                        select f.function_id;

                List<int> list = q.ToList();
                foreach (CheckBox cb in this.flpFunctionList.Controls)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i] == (int)cb.Tag)
                        {
                            cb.Checked = true;
                        }
                    }
                }
                #endregion

                #region step3: 載入商品介紹
                var qIntro = from intro in db.production_introduction
                             where intro.product_id == proID
                             select intro.introduction;

                if (qIntro.ToList().Count > 0)
                {
                    this.htmlEditor.InnerHtml = System.Web.HttpUtility.UrlDecode(qIntro.ToList()[0], Encoding.GetEncoding("UTF-8"));
                    //this.rtxIntroduction.Text = qIntro.ToList()[0];
                }

                #endregion

                #region step4: 載入圖片

                //TODO: TODOTODOTODOTODOTODO
                var qImage = from i in db.production_image
                             where i.product_id == proID
                             select i.image;

                if (qImage != null)
                {
                    for (int i = 0; i < qImage.ToList().Count; i++)
                    {
                        byte[] image = qImage.ToList()[i].ToArray();
                        listImageByte.Add(image);
                    }
                    imageOpen();
                }


                #endregion
            }
            else
            {
                // ...
            }

            this.Cursor = Cursors.Default;
        }



        private void btnAddProperty_Click(object sender, EventArgs e)
        {
            FrmProductProperty f = new FrmProductProperty();
            f.ShowDialog();
        }

        #region Picture
        //================================================================================================
        List<byte[]> listImageByte = new List<byte[]>();
        //List<string> filePathList = new List<string>();
        //List<string> FilePathListTemp = new List<string>();
        int temp1, temp2;
        byte[] temp;
        //string temp;

        //清空+釋放資源vvvvv
        private void ClearflpImageObject()
        {
            foreach (Control x in this.flpImage.Controls)
            {
                x.Dispose();
            }
            this.flpImage.Controls.Clear();
        }
        //清空+釋放資源^^^^^
        int ScrollValue;
        private void imageOpen()
        {
            //flpImage.Controls.Clear();
            ClearflpImageObject();
            //int XX = 0;
            //Point LL = new Point(XX, 0);
            //for (int i = 0; i < filePathList.Count; i++)
            for (int i = 0; i < listImageByte.Count; i++)
            {
                //  LL.X = XX;

                ProductPictureBox a = new ProductPictureBox();
                //a.Location = LL;
                a.Height = 110;
                a.Width = 90;
                //a.Height = this.flpImage.Height - 20;
                //a.Width = (this.flpImage.Width / 3) - 10;
                a.BorderStyle = BorderStyle.FixedSingle;
                //2進位轉成圖vvvvv
                MemoryStream ms = new MemoryStream(listImageByte[i]);
                Bitmap bmp = new Bitmap(ms);
                //2進位轉成圖^^^^^
                a.Image = bmp;
                //a.ImageLocation = filePathList[i];
                a.Tag = i;
                a.Picture.Tag = i;
                a.RightTitle.Tag = i;
                a.LeftTitle.Tag = i;
                a.LeftTitle.Text = string.Format("{0:d2}", i + 1); ;
                a.SizeMode = PictureBoxSizeMode.Zoom;
                flpImage.Controls.Add(a);
                //XX += 100;
            }
            foreach (Control x in this.flpImage.Controls)
            {
                x.AllowDrop = true;
                x.MouseDown += x_MouseDown;
                x.DragDrop += x_DragDrop;
                x.DragEnter += x_DragEnter;
                ((ProductPictureBox)x).RightTitle.MouseClick += RightTitle_MouseClick;
                ((ProductPictureBox)x).Picture.MouseDown += x_MouseDown;//2132113121321
            }
            this.flpImage.HorizontalScroll.Value = ScrollValue;
            this.flpImage.PerformLayout();
            return;
        }

        void RightTitle_MouseClick(object sender, MouseEventArgs e)
        {
            ScrollValue = this.flpImage.HorizontalScroll.Value;
            int WhichPictureWillBeDelete = int.Parse(((Label)sender).Tag.ToString());
            //if (filePathList.Count == listImageByte.Count)
            //{
            //    filePathList.Remove(filePathList[WhichPictureWillBeDelete]);
            //}
            listImageByte.Remove(listImageByte[WhichPictureWillBeDelete]);
            imageOpen();
            return;
        }

        private void x_MouseDown(object sender, MouseEventArgs e)
        {
            //throw new NotImplementedException();
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                //filePathList.Remove(filePathList[int.Parse(((PictureBox)sender).Tag.ToString())]);
                listImageByte.Remove(listImageByte[int.Parse(((ProductPictureBox)sender).Tag.ToString())]);
                imageOpen();
                return;
            }
            //if (((PictureBox)sender).ImageLocation != null)
            if (((PictureBox)sender).Image != null)
            {
                temp1 = int.Parse(((PictureBox)sender).Tag.ToString());
                this.DoDragDrop(((PictureBox)sender).Image, DragDropEffects.Copy);
                return;
            }
        }

        private void x_DragDrop(object sender, DragEventArgs e)
        {
            ScrollValue = this.flpImage.HorizontalScroll.Value;
            temp2 = int.Parse(((ProductPictureBox)sender).Tag.ToString());
            //排列
            if (temp1 > temp2)//後到前
            {
                temp = listImageByte[temp1];
                for (int i = temp1; i > temp2; i--)
                {
                    listImageByte[i] = listImageByte[i - 1];
                }
                listImageByte[temp2] = temp;
                //LOAD01();
                imageOpen();
            }
            else if (temp1 < temp2)//前到後
            {
                temp = listImageByte[temp1];
                for (int i = temp1; i < temp2; i++)
                {
                    listImageByte[i] = listImageByte[i + 1];
                }
                listImageByte[temp2] = temp;
                //LOAD01();
                imageOpen();
            }
            else//不變
            {
                return;
            }
            //排列
        }

        private void x_DragEnter(object sender, DragEventArgs e)
        {
            //throw new NotImplementedException();
            e.Effect = DragDropEffects.Copy;
        }

        private void btnAddImage_Click(object sender, EventArgs e)
        {
            //FilePathList.Clear();
            //FilePathListTemp = FilePathList;
            string[] filePath = null;
            openFileDialog1.Multiselect = true;
            openFileDialog1.Filter = "JPG(*.jpg,*.jpeg)|*.jpg|BMP(*.bmp)|*.bmp|GIF(*.gif)|*.gif|PNG|*.png|AllPicture(*.*)|*.jpg;*.png;*.bmp;*.gif";
            openFileDialog1.FileName = "";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (listImageByte.Count + openFileDialog1.FileNames.Length > 20)
                {// + filePathList.Count
                    MessageBox.Show("超過20張了");
                    //FilePathListTemp = FilePathList;
                    return;
                }
                filePath = openFileDialog1.FileNames;
                //for (int i = 0; i < filePath.Length; i++)
                //{
                //    filePathList.Add(filePath[i]);
                //}
                for (int i = 0; i < filePath.Length; i++)
                {
                    //檔案轉二進位vvvvv
                    FileStream fs = new FileStream(filePath[i], FileMode.Open, FileAccess.Read);//(label10.Text, FileMode.Open, FileAccess.Read);//注意有沒有多出看不見的字元(Unicode
                    byte[] buf = new byte[fs.Length];
                    fs.Read(buf, 0, (int)fs.Length);
                    fs.Close();
                    fs.Dispose();
                    //檔案轉二進位^^^^^
                    listImageByte.Add(buf);
                }
                imageOpen();
            }

            //================================================================================================
        }
        #endregion

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            this.btnAdd.Enabled = false;
            bool isOK = true;
            foreach (Control c in this.splitContainer1.Panel1.Controls)
            {
                if (c is TextBox)
                {
                    if (c.Text == string.Empty)
                    {
                        errorProvider1.SetError(c, "請輸入資訊");
                        errorProvider1.BlinkStyle = ErrorBlinkStyle.NeverBlink;
                        isOK = false;
                    }
                    else
                    {
                        errorProvider1.SetError(c, "");
                    }
                }
            }
            

            

            if (isOK)
            {
                #region 新增資料
                if (isProCreate)
                {
                    #region step1: 新增資料
                    UboxDataClassesDataContext db = new UboxDataClassesDataContext(conn);
                    production_product Product = new production_product();
                    Product.product_name = this.txtProductName.Text;
                    Product.size = this.txtSize.Text;
                    Product.weight = decimal.Parse(this.txtWeight.Text);
                    Product.battery_talk_time = decimal.Parse(this.txtTalkTime.Text);
                    Product.battery_capacity = this.txtBatteryCapacity.Text;
                    Product.color = this.txtColor.Text;
                    Product.price = decimal.Parse(this.txtPrice.Text);
                    Product.category_id = (int)this.cboCategory.SelectedValue;
                    Product.brand_id = (int)this.cboBrand.SelectedValue;
                    Product.connect_id = (int)this.cboConnStandard.SelectedValue;
                    Product.operating_system_id = (int)this.cboOS.SelectedValue;
                    Product.processor_core_id = (int)this.cboCore.SelectedValue;
                    Product.processor_speed_id = (int)this.cboSpeed.SelectedValue;
                    Product.screen_size_id = (int)this.cboScreenSize.SelectedValue;
                    Product.screen_resolution_id = (int)this.cboScreenResolution.SelectedValue;
                    Product.camera_resolution_front_id = (int)this.cboFrontCamera.SelectedValue;
                    Product.camera_resolution_rear_id = (int)this.cboRearCamera.SelectedValue;
                    Product.ram_id = (int)this.cboRam.SelectedValue;
                    Product.rom_id = (int)this.cboRom.SelectedValue;
                    Product.product_visible = true;
                    try
                    {
                        db.production_product.InsertOnSubmit(Product);
                        db.SubmitChanges();
                    }
                    catch(Exception ex)
                    {
                        string Exception = ex.ToString();
                        MessageBox.Show("資料存取發生錯誤，請稍後再試...");
                        this.Cursor = Cursors.Default;
                        return;
                    }
                    #endregion

                    #region step2: 擷取productID
                    var q = from p in db.production_product
                            where p.product_name == this.txtProductName.Text &&
                                  p.rom_id == (int)this.cboRom.SelectedValue
                            select p.product_id;
                    proID = q.ToList()[0];
                    #endregion

                    #region step3: 上傳其他功能
                    foreach (CheckBox cb in this.flpFunctionList.Controls)
                    {
                        if (cb.Checked)
                        {
                            production_product_funtion proFunction = new production_product_funtion();
                            proFunction.product_id = proID;
                            proFunction.function_id = (int)cb.Tag;
                            db.production_product_funtion.InsertOnSubmit(proFunction);
                            db.SubmitChanges();
                        }

                    }
                    #endregion

                    #region step4: 上傳產品介紹
                    production_introduction proIntroduction = new production_introduction();
                    proIntroduction.product_id = proID;
                    proIntroduction.introduction = System.Web.HttpUtility.UrlEncode(this.htmlEditor.InnerHtml, Encoding.GetEncoding("UTF-8"));
                    //proIntroduction.introduction = this.rtxIntroduction.Text;
                    db.production_introduction.InsertOnSubmit(proIntroduction);
                    db.SubmitChanges();
                    #endregion

                    #region step5: 上傳照片
                    for (int i = 0; i < listImageByte.Count;i++)//filePathList.Count; i++)
                    {
                        byte[] image = listImageByte[i];//System.IO.File.ReadAllBytes(filePathList[i]);
                        production_image proImage = new production_image();
                        proImage.product_id = proID;
                        proImage.image_order = (byte)(i + 1);
                        proImage.image = image;
                        db.production_image.InsertOnSubmit(proImage);
                        db.SubmitChanges();
                    }

                    db.Dispose();
                    MessageBox.Show("新增成功!");
                    this.Close();
                    #endregion
                }
            #endregion

                #region 修改資料
                else
                {
                    DialogResult result = MessageBox.Show("是否修改商品資訊", "系統提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        UboxDataClassesDataContext db = new UboxDataClassesDataContext(conn);

                        #region step1: 修改資料
                        production_product Product = db.production_product.First(p => p.product_id == proID);
                        Product.product_name = this.txtProductName.Text;
                        Product.size = this.txtSize.Text;
                        Product.weight = decimal.Parse(this.txtWeight.Text);
                        Product.battery_talk_time = decimal.Parse(this.txtTalkTime.Text);
                        Product.battery_capacity = this.txtBatteryCapacity.Text;
                        Product.color = this.txtColor.Text;
                        Product.price = decimal.Parse(this.txtPrice.Text);
                        Product.category_id = (int)this.cboCategory.SelectedValue;
                        Product.brand_id = (int)this.cboBrand.SelectedValue;
                        Product.connect_id = (int)this.cboConnStandard.SelectedValue;
                        Product.operating_system_id = (int)this.cboOS.SelectedValue;
                        Product.processor_core_id = (int)this.cboCore.SelectedValue;
                        Product.processor_speed_id = (int)this.cboSpeed.SelectedValue;
                        Product.screen_size_id = (int)this.cboScreenSize.SelectedValue;
                        Product.screen_resolution_id = (int)this.cboScreenResolution.SelectedValue;
                        Product.camera_resolution_front_id = (int)this.cboFrontCamera.SelectedValue;
                        Product.camera_resolution_rear_id = (int)this.cboRearCamera.SelectedValue;
                        Product.ram_id = (int)this.cboRam.SelectedValue;
                        Product.rom_id = (int)this.cboRom.SelectedValue;
                        try
                        {

                            db.SubmitChanges();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("" + ex);
                        }

                        #endregion

                        #region step2: 上傳其他功能


                        var f = from p in db.production_product_funtion
                                where p.product_id == proID
                                select p;

                        foreach (production_product_funtion proFunction in f)
                        {
                            db.production_product_funtion.DeleteOnSubmit(proFunction);
                        }

                        foreach (CheckBox cb in this.flpFunctionList.Controls)
                        {
                            if (cb.Checked)
                            {
                                production_product_funtion proFunction = new production_product_funtion();
                                proFunction.product_id = proID;
                                proFunction.function_id = (int)cb.Tag;
                                db.production_product_funtion.InsertOnSubmit(proFunction);
                                db.SubmitChanges();
                            }
                        }
                        #endregion

                        #region step3: 上傳產品介紹
                        production_introduction proIntroduction = db.production_introduction.First(i => i.product_id == proID);
                        proIntroduction.introduction = System.Web.HttpUtility.UrlEncode(this.htmlEditor.InnerHtml, Encoding.GetEncoding("UTF-8"));
                        //proIntroduction.introduction = this.rtxIntroduction.Text;
                        db.SubmitChanges();
                        #endregion

                        #region step4: 上傳照片

                        var qimage = from p in db.production_image
                                     where p.product_id == proID
                                     select p;

                        foreach (production_image proImage in qimage)
                        {
                            db.production_image.DeleteOnSubmit(proImage);
                        }

                        for (int i = 0; i < listImageByte.Count; i++)
                        {
                            production_image proImage = new production_image();
                            proImage.product_id = proID;
                            proImage.image_order = (byte)(i + 1);
                            proImage.image = listImageByte[i];
                            db.production_image.InsertOnSubmit(proImage);
                            db.SubmitChanges();
                        }

                        db.Dispose();
                        MessageBox.Show("修改成功!");
                        this.Close();
                        #endregion

                    }
                #endregion
            }

            }

            this.btnAdd.Enabled = true;
            this.Cursor = Cursors.Default;
        }
        #region 輸入限制-數字
        private void KeyPress_TextChanged(object sender, KeyPressEventArgs e)
        {
            if (((int)e.KeyChar < 48 | (int)e.KeyChar > 57) & (int)e.KeyChar != 8 & e.KeyChar!='.')
            {
                e.Handled = true;
            }
        }
        #endregion





        #region 按鈕樣式
        private void btnMouseEnter(object sender, EventArgs e)
        {
            ((Button)sender).FlatAppearance.BorderSize = 0;
            ((Button)sender).ForeColor = Color.White;
        }

        private void btnMouseLeave(object sender, EventArgs e)
        {
            ((Button)sender).FlatAppearance.BorderSize = 1;
            ((Button)sender).ForeColor = Color.Black;
        }
        #endregion

        private void btnDemo_Click(object sender, EventArgs e)
        {
            this.txtProductName.Text = "Apple i電話 Plus+ 256GB";
            this.txtBatteryCapacity.Text = "2100";
            this.txtColor.Text = "黑";
            this.txtPrice.Text = "30000";
            this.txtTalkTime.Text = "18";
            this.txtWeight.Text = "100";
            this.txtSize.Text = "100*20*300";
            this.cboBrand.SelectedIndex = 0;
            this.cboCategory.SelectedIndex = 0;
            this.cboConnStandard.SelectedIndex = 6;
            this.cboCore.SelectedIndex = 2;
            this.cboOS.SelectedIndex = 2;
            this.cboRam.SelectedIndex = 4;
            this.cboRom.SelectedIndex = 6;
            this.cboFrontCamera.SelectedIndex = 13;
            this.cboRearCamera.SelectedIndex = 8;
            this.cboScreenResolution.SelectedIndex = 6;
            this.cboScreenSize.SelectedIndex = 4;
            this.cboSpeed.SelectedIndex = 6;

            this.htmlEditor.InnerHtml = @"<span style=color:'#FF8C00'>蘋果 Apple i點喂 Plus+ 256GB 智慧型手機</span><br>
                                                                <span style='color:#0000FF'>創新，全面顯示</span><br>
                                                                蘋果推出萬眾囑目的巨大版 Apple i點喂 Plus+ 256GB 智慧型手機，外觀融入更薄的 7.1mm 光滑金屬機身，搭配 5.5 吋對角線 LED 背光寬螢幕、1,920 x 1,080pixels 螢幕解析度，與全新的 Retina HD 顯示器無縫接合，並採用雙域像素技術，令顯示器每個角落都保有準確色彩。即使從更廣的角度觀賞，電影與照片也栩栩如生。渾然一體的外表下，是硬體與軟體功能的完美融合。一切皆以美觀的陽極處理鋁金屬、不鏽鋼、玻璃所打造。還採用最先進的 Multi-Touch 多點觸控顯示器，結合更高對比度，以及更優質的偏光片等種種創新，能呈現出更黑、更銳利的文字，觀賞效果當然更佳。共有銀、金、太空灰三種顏色款式讓大家選擇。<br>
                                                                <br>
                                                                <span style='color:#0000FF'>每次體驗盡善盡美</span><br>
                                                                Apple i點喂 Plus+ 256GB 採用全新 iOS 8 作業系統，讓你實現之前只能想像的事，例如主畫面按鈕內建指紋身分識別感應器；Siri 來操控家中的裝置，或透過健康與健身 App 與醫生溝通。搭載 Apple A8 晶片，是以第二代 64 位元桌上型電腦等級的架構所打造，其非凡的威力因內建 Apple M8 動作感應協同處理器而更加傑出，還可透過全新氣壓感應器等多種先進感應器，能更有效率地度量你的一舉一動。A8 晶片也使用先進的 20 奈米製程，聚集二十億個電晶體，帶來難以置信的效能表現，其能源效率比起 A7 晶片提升 50%。內建 NFC 與 Touch ID 功能，支援蘋果最新推出的 Apple Pay 電子支付。除此之外，Apple i點喂 Plus+ 256GB 更支援 4G LTE 網路、Wi-Fi 802.11 ac 無線網路，讓使用者可體驗比起 802.11 n 更快，達 3 倍的 Wi-Fi 速度。因此，使用者能在更多地方連結更高速的無線網路。無論在瀏覽網頁、聆聽串流音樂、進行視訊通話，以及更多功能時，都能感受更快速的下載和上傳體驗。<br>
                                                                <br>
                                                                <span style='color:#0000FF'>令人讚賞的相機</span><br>
                                                                Apple i點喂 Plus+ 256GB 搭載 800 萬畫素 iSight 攝錄相機，除了支援 11.5µ 微米像素與 F2.2 大光圈外，可拍攝高達 4,300 萬像素全景照、每秒 60 影格的 1080P Full HD 影片、每秒 240 影格拍攝的慢動作影片功能，以及縮時攝影模式等。更具備 Focus Pixels 的全新感光元件、更強的臉孔偵測功能，以及曝光控制、連續自動對焦，讓你捕捉影片素材時能有持續穩定的焦點。即使拍攝時產生晃動，電影級視訊穩定功能，讓你的影片畫面依然穩定清晰。前端的 120 萬畫素 FaceTime 視訊鏡頭，具備更大的 F2.2 光圈和全新的感光元件技術，其攝入光線較以往多了 81%。它還擁有更強大的臉孔偵測功能，以及每秒可拍攝 10 張照片的全新連拍模式。因此，無論你想要拍張完美的自拍照或是想跨國聯繫某人，每個影像都可以自然出色。<br>
                                                                <br>
                                                                <span style='color:#0000FF'>Apple i點喂 Plus+ 256GB 功能特色</span><br>
                                                                ◎ 5.5 吋對角線 LED 背光寬螢幕 Multi-Touch 多點觸控顯示器、1,920 x 1,080pixels 螢幕解析度<br>
                                                                ◎ 採用全新 iOS 8 作業系統、主畫面按鈕內建指紋身分識別感應器<br>
                                                                ◎ 64 位元架構的 Apple A8 晶片、M8 動作感應協同處理器<br>
                                                                ◎ 800 萬畫素 iSight 攝錄相機、像素尺寸達 1.5µ、F2.2 光圈<br>
                                                                ◎ 1080P Full HD 錄影、Focus Pixels 感光元件、臉孔偵測、曝光控制、連續自動對焦<br>
                                                                ◎ 可拍攝最高 240FPS 的慢動作影片與最高 4,300 萬畫素的全景照片<br>
                                                                ◎ 120 萬畫素 FaceTime 視訊鏡頭、支援 720P HD 高畫質錄影、F2.2 光圈<br>
                                                                ◎ 支援 4G LTE 網路、Wi-Fi 802.11 a/b/g/n/ac 無線網路、NFC、藍牙 4.0<br>
                                                                ◎ 內建 128GB ROM 儲存空間<br>
                                                                <br>";
        }
        //================================左右移動卷軸================================
        private void timerL_Tick(object sender, EventArgs e)
        {
            if (listImageByte.Count > 3)
            {
                if(this.flpImage.HorizontalScroll.Value - 10 > 0)
                {
                    this.flpImage.HorizontalScroll.Value -= 10;
                }
                else
                {
                    this.flpImage.HorizontalScroll.Value = 0;
                }
            }
        }

        private void timerR_Tick(object sender, EventArgs e)
        {
            if (listImageByte.Count > 3)
            {
                if (this.flpImage.HorizontalScroll.Value + 10 < this.flpImage.Width + ((listImageByte.Count - 3) * 90))
                {
                    this.flpImage.HorizontalScroll.Value += 10;
                }
                else
                {
                    this.flpImage.HorizontalScroll.Value = this.flpImage.Width + ((listImageByte.Count - 3) * 90);
                }
            }
        }
        private void panelL_DragEnter(object sender, DragEventArgs e)
        {
            timerR.Enabled = false;
            timerL.Enabled = true;
        }

        private void panelL_DragLeave(object sender, EventArgs e)
        {
            timerL.Enabled = false;
            //this.flpImage.HorizontalScroll.Value = 20;
            //MessageBox.Show("1");
        }

        private void panelL_DragDrop(object sender, DragEventArgs e)
        {
            timerL.Enabled = false;
        }

        private void panelR_DragDrop(object sender, DragEventArgs e)
        {
            timerR.Enabled = false;
        }

        private void panelR_DragLeave(object sender, EventArgs e)
        {
            timerR.Enabled = false;
        }

        private void panelR_DragEnter(object sender, DragEventArgs e)
        {
            timerL.Enabled = false;
            timerR.Enabled = true;
        }
        //================================左右移動卷軸================================

    }

       








}

